/*
 * Copyright (c) 2019 Author: Fancyears Milos Malvis @1243093366@qq.com
 * ALL COPYRIGHT REVERSED.
 */

package com.fancyears.mq.consumer.direct;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

/**
 * @Author: Fancyears Milos Malvis
 * @Date: Created in  2019/5/31 13:24
 * @Modified By:
 */
@Component
public class RabbitMqDirectReceiver2 implements ChannelAwareMessageListener {
    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
//        try {
//            System.out.println("************************TopicErrorReceiver********************************");
//            System.out.println("路由模式接收信息:" + new String(message.getBody()));
//            System.out.println("********************************************************");
//            //设置手工应答
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//        } catch (Exception e) {
//            e.printStackTrace();
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//        }
    }

    @Override
    public void onMessage(Message message) {
        try {
            System.out.println("************************TopicErrorReceiver********************************");
            System.out.println("路由模式接收信息:" + new String(message.getBody()));
            System.out.println("********************************************************");

        } catch (Exception e) {
          e.printStackTrace();
        }
    }
}
